package myapp.commands 
{
	import myapp.AppRoot;
	import myapp.Model;
	import myapp.data.Config;

	import com.bumpslide.command.Command;
	import com.bumpslide.command.CommandEvent;

	import flash.display.Sprite;

	/**
	 * @author David Knape
	 */
	public class InitModel extends Command 
	{

		private var model:Model = Model.getInstance();			

		
		override public function execute(event:CommandEvent):void
		{	
			var flashvars:Object = getFlashVars(event.data as AppRoot);
			
			model.config = new Config(flashvars);
			 
			super.execute(event);
		}

		
		protected function getFlashVars(view:Sprite ):Object 
		{
			return (view.parent != null) ? view.parent.loaderInfo.parameters : view.loaderInfo.parameters; 
		}
	}
}
